<?php
namespace Admin\Controller;
use Admin\Controller\BaseController;
class MajorController extends BaseController {

    //专业列表
	public function index() {
        
        $count = M('major')->count();
        $page = getpage($count,10);
        $major_arr = M('major')->order('major_id asc')->limit($page->firstRow, $page->listRows)->select();
        $this->assign('major_arr', $major_arr);
        $this->assign('page', $page->show());
        $this->display();
    }

    public function major_edit() {
        if (I('post.action') == 'major_edit_action') {
            $this->major_edit_action();
            exit();
        }
        $data['major_id'] = I('get.major_id');
        $major_arr = M('major')->where($data)->find();
        $this->assign('major_arr', $major_arr);
        $this->display();
    }

    public function major_edit_action(){
        
        if(M('major')->save($_POST)){
            $this->success('修改专业信息成功','index');
        }else{
            $this->error('修改专业信息失败');
        }
    }


}